<?php
/**
 * @version		0.2.0 joomla zmluvy $
 * @package		com_zjmluvy
 * @copyright	Copyright © 2011 - All rights reserved.
 * @license		GNU/GPL
 * @author    AdrianKo		
 * @website   http://code.google.com/p/joomla-zmluvy
 *
 *
 *1.3.2012
 */

// no direct access
defined('_JEXEC') or die('Restricted access');

jimport('joomla.application.component.controller');

class jzmluvyController extends JController
{

	function __construct()
	{
		parent::__construct();
		
		// Registrace extra dotazu
		$this->registerTask( 'add'  , 	'display'  );
		$this->registerTask( 'edit'  , 	'display'  );
		$this->registerTask( 'apply', 	'save'  );
	}

  	/**
	 * Displays a view
	 */
/*	function display( )
	{
		switch($this->getTask())
		{
			case 'add'     :
			{	JRequest::setVar( 'hidemainmenu', 1 );
//				JRequest::setVar( 'layout', 'form'  );
				JRequest::setVar( 'view', 'uprava_kategorie' );
				JRequest::setVar( 'edit', false );
				
			} break;
			case 'edit'    :
			{
				JRequest::setVar( 'hidemainmenu', 1 );
//				JRequest::setVar( 'layout', 'form'  );
				JRequest::setVar( 'view', 'uprava_kategorie' );
				JRequest::setVar( 'edit', true );
			} break;
		}

		parent::display();
	}
	
		function save()
	{
		JRequest::checkToken() or die( 'Invalid Token' );
		
		$task		= JRequest::getVar('task');

		$post = JRequest::get( 'post' );
		$post['description'] = JRequest::getVar( 'description', '', 'post','string', JREQUEST_ALLOWRAW );
		$post['description']	= str_replace( '<br>', '<br />', $post['description'] );

		$model = $this->getModel('uprava_kategorie');
		
		$returnid = $model->store($post);

		if ($returnid) {

			switch ($task)
			{
				case 'apply' :
					$link = 'index.php?option=com_uredni_deska&view==uprava_kategorie&hidemainmenu=1&cid[]='.$returnid;
					break;

				default :
					$link = 'index.php?option=com_uredni_deska&view=kategorie';
					break;
			}
			$msg	= 'Kategorie přidána či upravena';

		} else {

			$msg 	= '';
			$link = 'index.php?option=com_uredni_deska&view=kategorie';

		}

//		$model->checkin();

		$this->setRedirect( $link, $msg );
 	} */
}
?>